bangkeapp.factory('commonService', ['$http', '$q', 'url', "userinfoService", "$ionicLoading",
function($http, $q, url, userinfoService, $ionicLoading) {
	
	var uploadfile = function(filebase64, filename) {
		
    		var result = {};
    		var data = userinfoService.getNewData();
		data.body.strFileBase64 = filebase64;
		data.body.strFileName = filename;
		
        var deferred = $q.defer();
        var promise = deferred.promise;
        var progress;
       	// 请求
		$http({
			method: "POST",
			url: url + "/file/baseuploadfile",  
			headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},
			//transformRequest: transform,
			params: {
				"body": angular.toJson(data)
			}
		}).success(function(response) {
			result = response;
			progress = response.header.ResponseCode;
			deferred.notify(progress);
			deferred.resolve(result);
		})
		.error(function(error) {
			deferred.reject(error);
		});
		return promise;
	};
	var getbankinfo = function() {
		
    		var result = {};
    		var data = userinfoService.getNewData();
		
        var deferred = $q.defer();
        var promise = deferred.promise;
        var progress;
       	// 请求
		$http({
			method: "GET",
			url: "data/bankinfo.json"
		}).success(function(response) {
			result = response;
			progress = response.header.ResponseCode;
			deferred.notify(progress);
			deferred.resolve(result);
		})
		.error(function(error) {
			deferred.reject(error);
		});
		return promise;
	};
	return {
		uploadfile : uploadfile, // 上传图片
		getbankinfo : getbankinfo // 银行信息
	};
}]);